package router4user

import (
	middlewares "Gin-Gorm-boke/boke_common/middlewares"
	controller4user "Gin-Gorm-boke/boke_user/yewu/controller4user"
	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.CorsMiddleWare())

	r.POST("/login", controller4user.Login)
	r.POST("/logout", controller4user.Logout)
	r.POST("/upload", controller4user.UploadAvatar)

	article := r.Group("/article")
	{
		article.GET("/hotArticleList", controller4user.GetHotArticleList)
		article.GET("/articleList", controller4user.GetArticleList)
		article.GET("/:id", controller4user.GetArticleById)
		article.PUT("/updateViewCount/:id", controller4user.UpdateViewCountByKafka)

	}
	category := r.Group("/category")
	{
		category.GET("/getCategoryList", controller4user.GetCategoryList)
	}
	link := r.Group("/link")
	{
		link.GET("/getAllLink", controller4user.GetAllLink)
	}
	comment := r.Group("/comment")
	{
		comment.GET("/commentList", controller4user.GetCommentList)
		comment.POST("", middlewares.AuthUserCheck(), controller4user.AddComment)
		comment.GET("/linkCommentList", controller4user.GetLinkCommentList)
	}
	user := r.Group("/user")
	{
		user.GET("/userInfo", middlewares.AuthUserCheck(), controller4user.GetUserInfo)
		user.PUT("/userInfo", middlewares.AuthUserCheck(), controller4user.UpdateUserInfo)
		user.POST("/register", controller4user.Register)
	}

	return r
}
